<template>
	<view class="g-detail">
		<image :src="goodsDetail.goodsImages" class="bimg" mode=""></image>
		<view class="cont-info">
			<view class="cont">
				商品名：{{goodsDetail.productName}}
				<view class="pric">
					费用：<text class="pr">¥{{num * goodsDetail.price}}</text>
				</view>
				<view class="pay-type">
					选择支付方式
					<view class="p-item">
						<image src="../../static/wx.png" class="wx" mode=""></image>
						<view class="p-r">
							微信支付
							<view class="desc">推荐已安装微信客户端使用</view>
						</view>
						<image src="../../static/check-pay.png" class="check-pay" mode=""></image>
					</view>
				</view>
			</view>
			<view class="p-hr"></view>
			<view class="p-bnt" @tap="goUrl('/pagesB/pay/payment')">
				确认支付
			</view>
		</view>
	</view>
</template>

<script>
	import {getGoodsInfo,createGoodsOrder} from '@/api/goods.js'
	export default {
		data() {
			return {
				goodsDetail: {},
				def: {},
				num: 1
			};
		},
		onLoad(ops) {
			this.def = ops
			this.getInfo()
			console.log('ops', ops)
		},
		methods:{
			goUrl(url){
				uni.navigateTo({
					url
				})
			},
			getInfo() {
				getGoodsInfo({id:this.def.id}).then((res) => {
					this.goodsDetail = res
					this.goodsDetail.elementsImages = res.elementsImages ? res.elementsImages.split(',') : []
					// this.num = this.goodsDetail.elementsImages.length
					this.goodsDetail.renderingImages = res.renderingImages ? res.renderingImages.split(',') : []
				})
				
				let order = {
					addressId: this.def.addrId,
					goodsCount: 1,
					goodsId: this.goodsDetail.id,
					goodsTotalPrice: this.num * this.goodsDetail.price,
					orderElementPic: this.def.orderElementPic,
					orderOrigin: this.def.orderOrigin,
					payAmount: this.num * this.goodsDetail.price,
					paymentType: 1,
					showId: this.def.showId,
					subjectId: this.def.supplierId
				}
				createGoodsOrder(order).then((res) => {
					console.log(res,'00000000000')
				})
			}
		}
	}
</script>

<style lang="less" scoped>
.g-detail{
	.bimg{
		width: 750rpx;
		height: 560rpx;
	}
	.cont-info{
		position: absolute;
		left: 0px;
		top: 504rpx;
		// bottom: 0;
		width: 750rpx;
		height: 944rpx;
		border-radius: 40rpx 40rpx 0px 0px;
		background: linear-gradient(180deg, #FFFFFF 4%, rgba(246,241,235,0.00) 100%);
		box-shadow: 0px 8rpx 20rpx 0px rgba(228, 73, 91, 0.05);
		
		.cont{
			font-size: 36rpx;
			margin: 0 32rpx;
			margin-top: 32rpx;
		}
		.pric{
			margin-top: 16rpx;
			.pr{
				color: #E4919D;
			}
		}
		.pay-type{
			font-size: 32rpx;
			color: #666;
			margin-top: 78rpx;
			.p-item{
				display: flex;
				align-items: center;
				margin-top: 48rpx;
				.wx{
					width: 88rpx;
					height: 88rpx;
					vertical-align: middle;
				}
				.check-pay{
					width: 48rpx;
					height: 48rpx;
				}
				.p-r{
					font-size: 32rpx;
					color: #333333;
					flex: 1;
					margin-left: 6rpx;
					.desc{
						font-size: 24rpx;
						color: #666;
					}
				}
			}
		}
		.p-hr{
			height: 1rpx;
			background-color: #e0e5e5;
			margin: 0 32rpx;
			margin-top: 24rpx;
		}
		.p-bnt{
			height: 98rpx;
			line-height: 98rpx;
			text-align: center;
			border-radius: 50rpx;
			background: #E4919D;
			color: #FFFFFF;
			font-size: 36rpx;
			margin: 0 32rpx;
			margin-top: 163rpx;
		}
	}
}
</style>
